package com.hongliang.mockito.common;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Hongliang Zhu
 * @create 2021-08-14 21:42
 */
public class AccoutLoginController {

    private AccountDao accountDao;

    public AccoutLoginController(AccountDao accountDao) {
        this.accountDao = accountDao;
    }

    public String login(HttpServletRequest request){
        final String username = request.getParameter("username");
        final String password = request.getParameter("password");

        try {
            Account account = accountDao.findAccount(username, password);
            if(account == null){
                return "/login";
            }else{
                return "/index";
            }
        }catch(Exception e){
            return "/505";
        }
    }

}
